<template>
	<basic-container>
		<avue-form ref="form" v-model="formData" :option="option" @submit="submitBtn">
			<template slot-scope="" slot="goodsId">
				<el-button type="primary" size="mini" @click="getshoresList">查看商品</el-button>
			</template>
			<template slot-scope="" slot="signingAreaName">
				<div style="line-height: 26px;">
					<el-tree
						:data="signingAreaOptions"
						:default-expanded-keys="['总分组']"
						node-key="id"
						ref="tree"
						empty-text=""
						highlight-current
						:props="props1"
					></el-tree>
				</div>
				<!-- <el-select v-model="formData.signingAreaName"  size="mini" placeholder="请选择" multiple collapse-tags @remove-tag="remove">
					<el-option value="" name="name"  style="height: auto"> -->
						
				<!-- 	</el-option>
				</el-select> -->
			</template>
			<template slot-scope="" slot="crossCondition">
				<div color="#fff" style="border: none;color: #333333;word-break: break-all;">
					{{formData.crossCondition}}
				</div>
			</template>
			<template slot="applyArea">
				<el-select v-model="formData.applyArea"  size="mini" placeholder="请选择" multiple collapse-tags @remove-tag="remove">
					<el-option :value="mineStatusValue" name="name"  style="height: auto">
						<el-tree
							:data="signOptions"
							:default-expanded-keys="['总分组']"
							show-checkbox
							node-key="id"
							ref="signTree"
							highlight-current
							:props="props1"
							@check="handleCheckChange"
						></el-tree>
					</el-option>
				</el-select>
			</template>
		</avue-form>
		<!-- 选择商品 -->
		<el-drawer :visible.sync="drawerGoods" :with-header="false" size="60%">
			<div class="demo-drawer__header">
				<div class="drawerHeader"><strong>商品列表</strong></div>
			</div>
			<div class="demo-drawer__content">
				<avue-crud
					ref="goodsCrud"
					:data="sellerGoodsList"
					:option="optionGoods"
					v-model="sellerGoods"
					:table-loading="sellerGoodsloading"
					:page="sellerGoodsPage"
					@selection-change="selectionChange"
					@refresh-change="refreshSellerGoodsChange"
					@search-change="searchSellerGoodsChange"
					@search-reset="searchSellerGoodsReset"
					@current-change="currentSellerGoodsChange"
					@size-change="sizeSellerGoodsChange"
					@on-load="onSellerGoodsLoad"
				>
					<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
						<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
					</template>

					<template slot-scope="{row,type,size}" slot="menu">
						<el-button  :size="size" :type="type"  @click="checkGoodsSoRange(row.id)">查看已可见范围</el-button>
					</template>

					<template slot="search">
						<el-col :span="12">
							<el-form-item label="商品分类" style="display: inline-block;width: 50%;">
								<el-cascader v-model="productData" :options="chooseProductOption" size="mini" @change="handleChange"></el-cascader>
							</el-form-item>
							<el-form-item label="本店分类" label-width="100px"  style="display: inline-block;width: 50%;">
								<el-cascader v-model="productUserData" :options="chooseProductUserOption" size="mini" @change="handleUserChange"></el-cascader>
							</el-form-item>
						</el-col>
					</template>

				</avue-crud>
				<el-button size="mini" type="primary" @click="addGoods()">确认</el-button>
			</div>

			<el-dialog title="查看该商品已可见范围"
					   :visible.sync="openGoodsSoRange"
					   append-to-body
					   width="50%"
					   :close-on-click-modal="false"
					   :show-close="false">
				<el-tree
						:data="checkSignOptions"
						show-checkbox
						node-key="id"
						ref="treeBack"
						:props="props2"
						highlight-current
						>
				</el-tree>
				<div style="margin: 50px auto;">
					<div style="width:200px;margin: 0px auto;">
						<el-button type="primary" size="mini" @click="closeThisDialog">关 闭</el-button>
					</div>
				</div>

			</el-dialog>

		</el-drawer>
	</basic-container>
</template>

<script>
import { getArealist } from '@/api/base/goods/seller/area.js';
	import {getOrganizationTreeNodeByIds } from '@/api/base/goods/goods';
	import { getOrganizationMapByLevel } from '@/api/base/goods/addGoods';
import { crossApplyPageInfo,goodsCrossApply } from '@/api/base/store/seller/crossBorder.js';
import { getList,showBack,getGoodsClassAll,getUserGoodsClassAll} from '@/api/base/goods/seller/goods';
import { mapGetters } from 'vuex';
export default {
	data() {
		return {
			signingAreaOptions: [],
			signOptions: [],
			checkSignOptions: [],
			postOptions:[],
			props1: {
				label: 'name',
				id: 'id',
				children: 'childrenNodes',
				disabled:'classDisplay'
			},
			props2: {
				label: 'name',
				id: 'id',
				children: 'childrenNodes'
			},
			mineStatusValue: [],
			distributionValues: [],
			productData: [],
			productUserData:[],
			chooseProductOption: [],
			chooseProductUserOption:[],
			drawerGoods: false,
			openGoodsSoRange:false,
			sellerGoodsList: [],
			sellerGoods: {},
			sellerGoodsloading: false,
			sellerGoodsQuery: {},
			sellerGoodsPage: {
				pageSize: 10,
				currentPage: 1,
				total: 0
			},
			sellerGoodsOption: {
				header: false,
				selection: true,
				// selectable: (row) => {
				// 	if(row.activityStatus) {
				// 		return false;
				// 	}else {
				// 		return true;
				// 	}
				// },
				menu: true,
				search: true,
				searchMenuSpan: 6,
				editBtn: false,
				delBtn: false,
				border: true,
				align: 'center',
				menuWidth: 100,
				column: [
					{
						label: '商品图片',
						prop: 'goodsMainPhotoUrl',
						width: 100,
						slot: true
					},
					{
						label: '商品名称',
						prop: 'goodsName',
						searchSpan: 8,
						align: 'left',
						search: true
					},
					{
						label: '指定分类',
						prop: 'goodsClassId',
						dicUrl: '/base/goodsClass/listManage',
						dicQuery: {
							classLevel: 2
						},
						width: 80,
						props: {
							label: 'className',
							value: 'id'
						},
						type: 'select',
						searchSpan: 8,
						search: true
					},
					{
						label: '总库存',
						prop: 'stock',
						width: 70,
						span: 24
					},
					{
						label: '商品原价（￥）',
						prop: 'originalPrice',
						width: 120,
						span: 24
					},
					{
						label: '商城售价（￥）',
						prop: 'showPrice',
						width: 120,
						span: 24
					}
				]
			},
			formData: {},
			option: {
				labelPosition: 'right',
				labelWidth: 300,
				gutter: 0,
				menuBtn: true,
				submitBtn: true,
				submitSize: 'mini',
				submitText: '提交',
				emptyBtn: false,
				menuPosition: 'center',
				column: [
					{
						label: '已通过平台上架审核的商品列表',
						prop: 'goodsId',
						span: 24,
						formslot: true,
						rules: [
						]
					},
					{
						label: '所属区域',
						prop: 'signingAreaName',
						formslot: true,
						span: 24
					},
					{
						label: '跨域申请条件',
						prop: 'crossCondition',
						formslot: true,
						span: 24
					},
					{
						label: '申请开通的商品可见范围',
						prop: 'applyArea',
						formslot: true,
						span: 24,
						multiple: true,
						dicData: '',
						type: 'tree',
						props: {
							label: 'name',
							value: 'id',
							children: 'childrenNodes'
						},
						required: true,
						rules: [
							{
								required: true,
								message: '请选择商品可见范围',
								trigger: 'change'
							}
						]
					},
					{
						type: 'textarea',
						label: '跨域申请理由',
						prop: 'reason',
						span: 24,
						required: true,
						rules: [
							{
								required: true,
								message: '请选择跨域申请理由',
								trigger: 'blur'
							}
						]
					}
				],
				
			},
			labelPosition: 'right',
			treeData: [],
			defaultProps: {
				children: 'children',
				label: 'label'
			},
			numberValidateForm: {},
			// rules: {
			// 	reason: [{ required: true, message: '请输入申请跨域理由', trigger: 'blur' }, { min: 2, max: 200, message: '申请跨域理由长度在 2 到 200 个字符', trigger: 'blur' }]
			// },
			checkeddataIds: [],
			checkeddataStr: [],
			obj: {},
			data: [
				{
					goodsName: '张三',
					stock: '男',
					goodsSort: '1994-02-23 00:00:00'
				},
				{
					goodsName: '李四',
					stock: '女',
					goodsSort: '1994-02-23 00:00:00'
				},
				{
					goodsName: '王五',
					stock: '女',
					goodsSort: '1994-02-23 00:00:00'
				},
				{
					goodsName: '赵六',
					stock: '男',
					goodsSort: '1994-02-23 00:00:00'
				}
			],
			page: {
				pageSize: 10,
				currentPage: 1,
				total: 0
			},
			loading: false,
			optionGoods: {
				size: 'mini',
				excelBtn: false,
				selection:true,
				tip: false,
				reserveSelection:true,
				page:false,
				// selectable: (row) => {
				// 	if(row.activityStatus) {
				// 		return false;
				// 	}else {
				// 		return true;
				// 	}
				// },
				addBtn: false,
				border: true,
				index: false,
				selection: true,
				editBtn: false,
				viewBtn: false,
				delBtn: false,
				searchBtn: false,
				refreshBtn: false,
				columnBtn: false,
				rowKey: 'id',
				height: 600,
				dialogType: 'dialog',
				menuWidth: 150,
				menuAlign: 'center',
				align: 'center',
				searchMenuSpan: 8,
				column: [
					{
						label: '商品名称',
						prop: 'goodsName',
						align: 'left',
						fixed: true,
						search: true,
						rules: [
							{
								required: true,
								message: '请输入商品名称',
								trigger: 'blur'
							}
						]
					},
					{
						label: '商品图片',
						prop: 'goodsMainPhotoUrl',
						width: 150,
						slot: true,
						rules: [
							{
								required: true,
								message: '请输入主图片',
								trigger: 'blur'
							}
						]
					},

					{
						label: '商品分类',
						prop: 'goodsClassId',
						dicUrl: 'base/sellerGoodsClass/listDicData',
						props: {
							label: 'label',
							value: 'value'
						},
						width: 150
					},

					{
						label: '本店分类',
						prop: 'userGoodsClassId',
						dicUrl: 'base/sellerUserGoodsClass/listDicData',
						props: {
							label: 'label',
							value: 'value'
						},
						width: 150
					},

					{
						label: '商城售价(￥)',
						prop: 'showPrice',
						rules: [
							{
								required: true,
								message: '请输入商城售价',
								trigger: 'blur'
							}
						],
						width: 100
					},

					{
						label: '库存量',
						prop: 'stock',
						rules: [
							{
								required: true,
								message: '请输入商品价格',
								trigger: 'blur'
							}
						],
						width: 100
					}
					// {
					// 	label: '商品已可见范围',
					// 	prop: 'goodsSort'
					// }
				]
			},
			allApplyTwo:[],//全选区域
			allApplyThree:[],//全选分公司
			applyAreaTwoAreaIds:[],//二级id
			halfApplyThree:[],//半选分公司
			allApplyFour:[],//小区全选
			fourLevel:[],
			map:[],//结果
		};
	},
	components: {},
	computed: {
		...mapGetters(['permission', 'userInfo']),
		permissionList() {
			return {
				addBtn: this.vaildData(this.permission['/mall-cloud-base/sellerGoods/addItem'], false)
			};
		}
	},

	created() {
		this.getArealistFn();
		this.getCross()
	},

	watch: {},

	methods: {
		//选择事件
		handleCheckChange() {
			this.allApplyTwo = []
			this.allApplyThree = []
			this.allApplyFour = []
			this.applyAreaTwoAreaIds = []
			this.halfApplyThree = []
			let res1 = this.$refs.signTree.getHalfCheckedNodes();
			let res = this.$refs.signTree.getCheckedNodes();
			let arrLabel = [];
			let arr = [];
			let ids= []
			this.map = []
			//全选
			res.forEach(item => {
				arrLabel.push(item.name);
				arr.push(item);
				ids.push(item.id)
				if(item.levelm==2  ){//区域
					this.allApplyTwo.push(item)
					this.applyAreaTwoAreaIds.push(item.id)
				}
				if(item.levelm==3){//分公司
					this.allApplyThree.push(item)
				}
				if(item.levelm==4){//分公司
					this.allApplyFour.push(item)
				}
			});
			//半选
			res1.forEach(item => {
				arrLabel.push(item.name);
				arr.push(item);
				ids.push(item.id)
				if(item.levelm==2  ){//区域
					this.applyAreaTwoAreaIds.push(item.id)
				}
				if(item.levelm==3){//分公司
					this.halfApplyThree.push(item)
				}
			});
		
			this.mineStatusValue = arr;
			this.formData.applyArea = arrLabel;
			this.formData.applyAreaId = ids;
			this.getMapList()
		},
		getMapList(){
			let mapIds=[]
			let mapNames=[]
			let threeIds= []//全选分公司 用于过滤
			let data = {}
			this.map = []
			//全选区域 可以直接全部取出 记录全选的分公司过滤全选中的分公司
			this.allApplyTwo.forEach(item=>{
				mapIds=[]
				mapNames=[]
				data = {}
				mapIds.push(item.parentId)
				mapNames.push(this.fourLevel[item.parentId])
				mapIds.push(item.id)
				mapNames.push(item.name)
				item.childrenNodes.forEach(child1=>{
					mapIds.push(child1.id)
					threeIds.push(child1.id)
					child1.childrenNodes.forEach(child2=>{
						mapIds.push(child2.id)
					})
				})
				data={
					ids:mapIds,
					pId:item.id,
					names:mapNames
				}
				this.map.push(data)
			})
			//全选分公司 过滤掉全选区域所属的分公司
			this.allApplyThree.forEach(item=>{
				mapIds=[]
				mapNames=[]
				data = {}
				if(threeIds.indexOf(item.id)==-1){
					mapIds.push(item.grandFatherId)
					mapNames.push(this.fourLevel[item.grandFatherId])
					mapIds.push(item.parentId)
					mapNames.push(this.fourLevel[item.parentId])
					mapIds.push(item.id)
					mapNames.push(this.fourLevel[item.id])
					item.childrenNodes.forEach(child1=>{
						mapIds.push(child1.id)
						threeIds.push(child1.id)
						child1.childrenNodes.forEach(child2=>{
							mapIds.push(child2.id)
						})
					})
				}
				if(mapIds.length>0){
					data={
						ids:mapIds,
						pId:item.parentId,
						names:mapNames
					}
					this.map.push(data)
				}
			})
			
			console.log(this.allApplyFour)
			//半选分公司 
			this.halfApplyThree.forEach(item=>{
				mapIds=[]
				mapNames=[]
				data = {}
				mapIds.push(item.grandFatherId)
				mapNames.push(this.fourLevel[item.grandFatherId])
				mapIds.push(item.parentId)
				mapNames.push(this.fourLevel[item.parentId])
				mapIds.push(item.id)
				mapNames.push(this.fourLevel[item.id])
				item.childrenNodes.forEach(child1=>{
					this.allApplyFour.forEach(fourId=>{
						if(fourId.id==child1.id){
							mapIds.push(child1.id)
							mapNames.push(child1.name)
						}
					})
				})
				data={
					ids:mapIds,
					pId:item.parentId,
					names:mapNames
				}
				this.map.push(data)
			})
			
			console.log(this.map)
		},
		//删除已选中的所有的
		remove(val) {
			this.formData.applyArea = '';
			this.$refs.tree.setCheckedKeys([]);
			// this.$refs.tree.setChecked(val, false);
			// let arr = this.$refs.tree.getCheckedNodes();
			// for (let i in arr) {
			// 	this.formData.applyArea.push(arr[i].name);
			// }
		},
		//确认申请
		submitBtn(loading,done) {
			this.loading = true
			if(this.formData.goodsId && this.formData.goodsId.length>0){
				this.formData.processListJson = JSON.stringify(this.map)
				this.formData.applyAreaTwoAreaIds = JSON.stringify(this.applyAreaTwoAreaIds)
				goodsCrossApply(this.formData).then(res=>{
					if(res.data.code==200){
						this.$message.success('申请成功！')
						this.loading = false
						this.mineStatusValue = [];
						this.map = []
						this.$refs.goodsCrud.toggleSelection();
						this.$nextTick(() => {
							this.$refs['form'].resetForm();
							this.$refs['form'].clearValidate();
						});
						this.getArealistFn();
						this.getCross()
						done()
					}else{
						done()
						this.$message.error(res.data.message)
					}
					
				})
			}
			else {
				done();
				this.$message.error("请先选择商品!");
			}

			console.log('tijiao');
			console.log(this.formData);
		},
		// openWin(item){
		// 	window.open(item)
		// },
		cancel() {
			this.drawerGoods = false;
		},
		addGoods() {
			console.log(this.formData.goodsId)
			if(this.formData.goodsId){
				if(this.formData.goodsId.length > 0){
					this.drawerGoods = false;
				}
				else {
					this.drawerGoods = true;
					this.$message.error("至少选择一个商品!");
				}
			}
			else {
				this.drawerGoods = true;
				this.$message.error("至少选择一个商品!");
			}
		},

		//查看该商品的已可见范围
		checkGoodsSoRange(id){
			console.log(this.checkSignOptions);
			showBack(id).then(res => {
				if(res.data.success){
					console.log(res.data.data);
					if(res.data.data.length>0){
						this.openGoodsSoRange = true;
						setTimeout(()=>{
							this.$refs.treeBack.setCheckedKeys(res.data.data);
						},1000)
					}else{
						this.$message.warning('该商品未设置可见区域！');
					}
					// setTimeout(()=>{
					// 	res.data.data.forEach(value => {
					// 		this.$refs.treeBack.setChecked(value, true, false);
					// 	});
					// },1000)
				}
				else{
					this.$message.error(res.data.message);
				}
			})
		},

		//关闭该商品的已可见范围弹框
		closeThisDialog(){
			this.openGoodsSoRange = false;
			this.getArealistFn();
			this.getCross()
		},

		//加载节点
		loadNode(node, resolve) {
			if(node.level === 0) {
				return resolve(this.listTree);
			}
			if(node.level === 1) {
				for(let i = 0; i < this.listTree.length; i++) {
					if(node.label == this.listTree[i].label) {
						return resolve(this.listTree[i].children);
					}
				}
			}
			if(node.level > 1) return resolve([]);

		},

		//节点被点击时触发
		nodeClick(a, node, c) {
			this.isClickNode = true;
			console.log("点击了节点");
		},

		//节点被展开时触发的事件（只有被展开时才会被触发）
		handleNodeExpand(data, node, c) {
			this.isClickTreeLeftIcon = true;
			console.log("点击左边的下图标，被展开了");
		},

		//节点被收起
		nodeCollapse(data, node, c) {
			this.isClickTreeLeftIcon = false;
			console.log("点击左边的下图标，被合起来了");
		},

		// 新增时 选择赠品 商品表格方法
		searchSellerGoodsReset() {
			this.sellerGoodsQuery = {};
			this.productData = [];
			this.productUserData = [];
			this.onSellerGoodsLoad(this.sellerGoodsPage);
		},
		searchSellerGoodsChange(params) {
			this.sellerGoodsPage.currentPage = 1;
			this.$refs.goodsCrud.toggleSelection();
			console.log(this.productData);
			console.log(this.productUserData);
			if (this.productData != undefined) {
				if(this.productData.length == 0){
					params.goodsClassId ="";
				}

			}

			if(this.productUserData != undefined){
				if(this.productUserData.length == 0){
					params.userGoodsClassId = "";
				}
			}
			this.sellerGoodsQuery = params;
			this.onSellerGoodsLoad(this.sellerGoodsPage, params);
		},
		
		currentSellerGoodsChange(currentPage) {
			this.sellerGoodsPage.currentPage = currentPage;
			this.onSellerGoodsLoad(this.sellerGoodsPage);
		},
		sizeSellerGoodsChange(pageSize) {
			this.sellerGoodsPage.pageSize = pageSize;
			this.onSellerGoodsLoad(this.sellerGoodsPage);
		},
		refreshSellerGoodsChange() {
			this.currentSellerGoodsChange(1);
			this.onSellerGoodsLoad(this.sellerGoodsPage);
		},
		onSellerGoodsLoad(sellerGoodsPage, params = {}) {
			params.goodsStatus = '0';
			if (this.productData != undefined) {
				if(this.productData.length>0){
					params.goodsClassId = this.productData[this.productData.length-1];
				}

			}

			if(this.productUserData != undefined){
				if(this.productUserData.length>0){
					params.userGoodsClassId = this.productUserData[this.productUserData.length-1];
				}
			}

			this.sellerGoodsloading = true;
			getList(sellerGoodsPage.currentPage, sellerGoodsPage.pageSize, Object.assign(params, this.sellerGoodsQuery)).then(res => {
				this.sellerGoodsloading = false;
				const data = res.data;
				this.sellerGoodsPage.total = data.count;
				data.data.forEach(item => {
					item.showPrice = item.goodsPriceBean.showPrice;
					item.originalPrice = item.goodsPriceBean.originalPrice;
				});
				this.sellerGoodsList = data.data;
			});
		},
		getCross(){
			crossApplyPageInfo().then(res=>{
				console.log(res)
				if(res.data.code==200){
					// signingAreaName
					
					getOrganizationTreeNodeByIds(res.data.data.operatingArea).then(res => {
						if (res.data.code == 200) {
							this.signingAreaOptions = res.data.data;
						}
					});
					this.formData=res.data.data;
					this.signOptions=res.data.data.organization.data;
					this.checkSignOptions = res.data.data.organization.data;
					if(this.checkSignOptions.length>0){
						this.checkSignOptions.forEach(item => {
							//1
							item.disabled = true;
							if(item.childrenNodes.length>0){
								item.childrenNodes.forEach(itemChild => {
									//2
									itemChild.disabled = true;
									if(itemChild.childrenNodes.length>0){
										itemChild.childrenNodes.forEach(inneredItemChild =>{
											//3
											inneredItemChild.disabled = true;
											if(inneredItemChild.childrenNodes.length>0){
												inneredItemChild.childrenNodes.forEach(innerestItemChild =>{
													//4
													innerestItemChild.disabled = true;
													if(innerestItemChild.childrenNodes.length>0){
														innerestItemChild.childrenNodes.forEach(theLastChild =>{
															//5
															theLastChild.disabled = true;
														})
													}
												})
											}
										})
									}
								})
							}
						})
					}
				}else{
					this.$message.error(res.data.message)
				}
				this.$nextTick(() => {
					this.$refs['form'].clearValidate();
				});
				console.log(this.formData)
				console.log(this.option.column[3])
			})
		},
		// 获取区域数据
		getArealistFn() {
			getArealist().then(res => {
				if (res.data.code == 200) {
					let data = res.data.data;
					let arr = [];
					for (let i of data) {
						let a = {};
						a.id = i.id;
						a.label = i.areaName;
						if (i.provines.length > 0) {
							let chilarr = [];
							for (let j of i.provines) {
								let b = {};
								b.id = j.id;
								b.label = j.areaName;
								if (j.childs.length > 0) {
									let grandchild = [];
									for (let k of j.childs) {
										let c = {};
										c.id = k.id;
										c.label = k.areaName;
										grandchild.push(c);
									}
									b.children = grandchild;
								} else {
									b.children = [];
								}
								chilarr.push(b);
							}
							a.children = chilarr;
						} else {
							a.children = [];
						}
						arr.push(a);
					}
					this.treeData = arr;
				}
			});
			getOrganizationMapByLevel({level:''}).then(res => {
				if (res.data.code == 200) {
					this.fourLevel = res.data.data;
				}
			});
		},
		//选择商品的回调
		selectionChange(list) {
			console.log(list)
			this.formData.goodsId = []
			list.forEach((item, index) => {
				// if (item.activityStatus) {
				// 	this.$refs.goodsCrud.toggleSelection(index);
				// } else {
				this.formData.goodsId[index] = item.id
				// }
			})
			console.log(this.formData.goodsId)
		},
		// 获取商品列表
		getshoresList() {
			this.drawerGoods = true;
			getGoodsClassAll().then(res => {
				if (res.data.code == 200 && res.data.data) {
					this.chooseProductOption = res.data.data;
				}
			});

			getUserGoodsClassAll().then(res => {
				if (res.data.code == 200  && res.data.data) {
					this.chooseProductUserOption = res.data.data;
				}
			});
			console.log('被点击了');
		},
		searchChange(params, done) {
			this.page.currentPage = 1;
			this.$refs.crud.toggleSelection();
			this.query = params;
			this.onLoad(this.page, params, done);
		},
		searchReset() {
			this.query = {};
			this.$refs.crud.toggleSelection();
			this.searchForm = {};
			this.productData = [];
			this.productUserData = [];
			this.onLoad(this.page);
		},
		// 选择项发生变化触发函数
		selectChange() {},
		currentChange(currentPage) {
			this.page.currentPage = currentPage;
			this.onLoad(this.page);
		},
		sizeChange(pageSize) {
			this.page.pageSize = pageSize;
			this.onLoad(this.page);
		},
		refreshChange() {
			this.onLoad(this.page);
		},
		onLoad(page, params = {}, done) {
			params.goodsStatus = 0;
			this.loading = true;
			getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
				if (done) {
					done();
				}
				this.loading = false;
				const data = res.data;
				this.page.total = data.count;
				if (res.status == 200) {
					// this.data = data.data.map(item => {
					// 	item['originalPrice'] = item.goodsPriceBean.originalPrice;
					// 	item['showPrice'] = item.showPrice;
					// 	return item;
					// });
					console.log(this.data);
				}
			});
		},
		handleChange(value) {
			console.log(value);
			this.sellerGoodsPage.currentPage = 1
			this.$refs.goodsCrud.toggleSelection();
			console.log(this.sellerGoodsQuery);
			let _goodsName ="";
			if(this.sellerGoodsQuery.goodsName){
				_goodsName = this.sellerGoodsQuery.goodsName;
			}
			this.sellerGoodsQuery = value;
			this.sellerGoodsQuery.goodsName = _goodsName;
			this.onSellerGoodsLoad(this.sellerGoodsPage);
		},

		handleUserChange(value) {
			console.log(value);
			this.sellerGoodsPage.currentPage = 1
			this.$refs.goodsCrud.toggleSelection();
			let _goodsName ="";
			if(this.sellerGoodsQuery.goodsName){
				_goodsName = this.sellerGoodsQuery.goodsName;
			}
			this.sellerGoodsQuery = value;
			this.sellerGoodsQuery.goodsName = _goodsName;
			this.onSellerGoodsLoad(this.sellerGoodsPage);
		},
	}
};
</script>

<style scoped>
	.drawerHeader {
		font-size: 20px;
		padding: 5px 20px;
	}
	.demo-drawer__content{
		padding: 50px;
	}
</style>
